package com.snake.springboot.custom.controller.points;

import com.snake.springboot.custom.api.model.points.PointsRgeTempModel;
import com.snake.springboot.custom.api.request.page.PageQuery;
import com.snake.springboot.custom.api.request.points.PointsRgeTempQuery;
import com.snake.springboot.custom.api.service.points.PointsRgeTempService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.snake.common.result.ResponseResult;
import org.snake.common.result.ResponseResultFactory;
import org.snake.common.result.ReturnList;
import org.snake.common.validate.Create;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * <p>算力管理-算力购买模板
 * 类{@code PointsRgeTemp} </br>
 * 创建时间2025/2/20 17:35
 * @author yangxt
 * @see
 */
@Api(tags = "算力管理-算力购买模板")
@RestController
@RequestMapping("/points/rge-temp")
public class PointsRgeTempController {

    private PointsRgeTempService tempService;
    @Autowired
    public PointsRgeTempController(PointsRgeTempService tempService) {
        this.tempService = tempService;
    }

    @ApiOperation("新增")
    @PostMapping("/add")
    public ResponseResult<PointsRgeTempModel> addPointsRgeTemp(
            @ApiParam(name = "接口入参", value = "传入json格式", required = true)
            @RequestBody @Validated({Create.class}) PointsRgeTempModel model) {
        PointsRgeTempModel result = tempService.addPointsRgeTemp(model);
        return ResponseResultFactory.ucc("添加成功！", result);
    }

    @ApiOperation("修改")
    @PostMapping("/modify")
    public ResponseResult<PointsRgeTempModel> modifyPointsRgeTemp(
            @ApiParam(name = "接口模型入参", value = "传入json格式", required = true)
            @RequestBody PointsRgeTempModel model) {
        tempService.modifyPointsRgeTemp(model);
        return ResponseResultFactory.ucc("修改成功！");
    }

    @ApiOperation("删除")
    @GetMapping("/remove/{id}")
    public ResponseResult<Object> remove(
            @ApiParam(name = "记录ID", value = "传入String类型", required = true)
            @PathVariable("id") String id) {
        tempService.removePointsRgeTemp(id);
        return ResponseResultFactory.ucc("移除成功！");
    }

    @ApiOperation("查询列表")
    @PostMapping("/list")
    public ResponseResult<ReturnList<PointsRgeTempModel>> queryPointsRgeTempList(
            @ApiParam(name = "查询条件", value = "传入json类型", required = true)
            @RequestBody PageQuery<PointsRgeTempQuery> params) {
        ReturnList<PointsRgeTempModel> result = tempService.queryPointsRgeTempList(params);
        return ResponseResultFactory.ucc("查询成功！", result);
    }
}
